package com.kuqi.core;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.kuqi.entitiy.UserInfo;

//对所有activity的可控性监听
public class ApplicationManager implements Application.ActivityLifecycleCallbacks {

    //单例模式,静态唯一
    private static ApplicationManager instance;

    //初始化方法,建立一个监控程序并注册到application中
    public static ApplicationManager init(Application application) {
        if (instance == null) {
            instance = new ApplicationManager();
            application.registerActivityLifecycleCallbacks(instance);
        }
        return instance;
    }

    //get方法
    public static ApplicationManager getInstance() {
        return instance;
    }


    //==================================================================================================


    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
        Log.e("生命周期监听程序-创建:", activity.getLocalClassName());
    }

    @Override
    public void onActivityStarted(@NonNull Activity activity) {
        Log.e("生命周期监听程序-开始:", activity.getLocalClassName());
    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {
        Log.e("生命周期监听程序-重置:", activity.getLocalClassName());
    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {
        Log.e("生命周期监听程序-暂停:", activity.getLocalClassName());
    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {
        Log.e("生命周期监听程序-停止:", activity.getLocalClassName());
    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
        Log.e("生命周期监听程序-保存状态:", activity.getLocalClassName());
    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {
        Log.e("生命周期监听程序-销毁:", activity.getLocalClassName());
    }
}

